using System;
using System.Collections;
using System.Collections.Generic;

namespace Phoenix.Framework
{
    public class QueryStringArgumentsCollection : IEnumerable<KeyValuePair<string, string>>
    {
        readonly Dictionary<string, string> lookup;

        public QueryStringArgumentsCollection(IEnumerable<KeyValuePair<string, string>> arguments = null)
        {
            lookup = new Dictionary<string, string>();
            if (arguments == null) return;
            foreach (var keyValuePair in arguments)
            {
                lookup.Add(keyValuePair.Key, keyValuePair.Value);
            }
        }

        public string this[string name]
        {
            get { return lookup[name]; }
        }

        public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
        {
            return lookup.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public int Count { get { return lookup.Count; } }
    }
}